<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid']);
	$params['uniacid']=$_SESSION['uniacid'];
	if($_RQ['status']){
			$params['mid']=$_RQ['mid'];
	}
	if(isset($_RQ['key'])){
			$params['key']=$_RQ['key'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_xunichong_record',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$v){
				$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
				$v['typetitle']=$this->credit_type[$v['type']];
			}
		}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(			
			array('name'=>'key','title'=>'兑换码','type'=>'string'),			
			array('name'=>'type','title'=>'兑换类型','type'=>'radio','options'=>'type'),
			array('name'=>'balance','title'=>'面额','type'=>'string'),
			array('name'=>'mid','title'=>'兑换人会员id','type'=>'string'),
			array('name'=>'nickname','title'=>'兑换人昵称','type'=>'string'),
			array('name'=>'createtime','title'=>'兑换时间','type'=>'time'),
		),
		),
		'search'=>array(
			array('name'=>'key','width'=>15,'title'=>'兑换码','type'=>'string'),
			array('name'=>'mid','width'=>15,'title'=>'会员id','type'=>'string'),
			
		)
	);
	$return['type']=$this->credit_type;
	$return['htmls']=$htmls;
	exi($return);
}
